package puzzle.projecteuler.p100;

import puzzle.projecteuler.ContinuedFraction;
import puzzle.projecteuler.Fraction;

public class Problem065 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Integer[] pre = new Integer[100];
		pre[0] = 2;
		for (int i = 1; i < 100; i ++) {
			if (i % 3 == 2) {
				pre[i] = 2*(i+1)/3;
			} else {
				pre[i] = 1;
			}
		}
		ContinuedFraction cf = new ContinuedFraction(pre, new Integer[]{});
		Fraction f = cf.fractionValue(100);
		
		int c = 0;
		char[] a = f.getNumerator().toString().toCharArray();
		for (int i = 0; i < a.length; i ++) {
			c += a[i]-'0';
		}
		System.out.println(c);
		
	}
}
